<template>
	<uv-navbar :fixed="true" :placeholder="true" :title="title" left-arrow @leftClick="$onClickLeft" />

	<view class="base-message">

		<uv-cell-group title="">
			<uv-cell title="编号：" :value="detailData.number"></uv-cell>
			<uv-cell title="工单名称：" :value="detailData.title"></uv-cell>
			<uv-cell title="状态：">
				<!-- 自定义右侧值 -->
				<template v-slot:value>
					<text class="cus-value">{{stateMapping[detailData.state] || ''}}</text>
				</template>
			</uv-cell>
			<uv-cell title="超时状态：" :value="detailData.outState">
				<!-- 自定义右侧值 -->
				<template v-slot:value>
					<text class="cus-value">{{outStateMapping[detailData.outState] || ''}}</text>
				</template>
			</uv-cell>
			<uv-cell title="超时时长：" :value="detailData.timeoutHour"></uv-cell>
			<uv-cell title="发起人：" :value="detailData.creater?.userName || ''"></uv-cell>
			<uv-cell title="发起时间：" :value="detailData.originatingTime"></uv-cell>
			<uv-cell title="处理人：" :value="detailData.numbprocessor?.userName"></uv-cell>
			<uv-cell title="计划处理时间：" :value="detailData.planStartTime"></uv-cell>
			<uv-cell title="计划用时(h)：" :value="detailData.planTime"></uv-cell>
			<uv-cell title="实际处理时间：" :value="detailData.realityStartTime"></uv-cell>
			<uv-cell title="实际用时(h)：" :value="detailData.realityTime"></uv-cell>
			<uv-cell title="验证人：" :value="detailData.validator?.userName"></uv-cell>
			<uv-cell title="偏差字段：" :value="detailData.deviation"></uv-cell>
			<uv-cell title="电站：" :value="detailData.powerstationName"></uv-cell>
			<uv-cell title="设备类型：" :value="detailData.deviceTypeName"></uv-cell>
			<uv-cell title="设备：" :value="detailData.deviceName"></uv-cell>
			<uv-cell title="告警信息：" :value="detailData.alarmName"></uv-cell>
			<uv-cell title="优先级：" :value="detailData.priority">
				<!-- 自定义右侧值 -->
				<template v-slot:value>

					<text class="cus-value">{{priorityMapping[detailData.priority] || ''}}</text>
				</template>

			</uv-cell>
		</uv-cell-group>

	</view>

</template>

<script setup>
	import {
		ref,
		reactive,
		getCurrentInstance
	} from "vue"
	import {
		onLoad
	} from "@dcloudio/uni-app"
	import {
		reqChargeDetail
	} from "@/api/model/chargingStation"
	import {
		reqOrderDetail
	} from "@/api/operate"
	const title = ref('工单详情')
	const detailData = ref({

	})
	const stateMapping = {
		0: '待接受',
		1: '待处理',
		2: '执行中',
		3: '待验证',
		5: '已完成',
		6: '拒绝接受',
		8: '已终止',
	};
	const outStateMapping = {
		0: '未超时',
		1: '已超时'
	}

	const priorityMapping = {
		0: '较低',
		1: '普通',
		2: '紧急',
		3: '非常紧急',
	}
	const getDetail = async (id) => {
		let {
			data
		} = await reqOrderDetail(id)
		console.log("详情数据", data)
		detailData.value = data.data
	}

	onLoad((option) => {
		const instance = getCurrentInstance().proxy;
		const eventChannel = instance.getOpenerEventChannel()
		getDetail(option.id)
		// eventChannel.on('getAlarmId', (data) => {
		// 	getDetail(option.alarmId)
		// })

	})
</script>

<style lang="scss" scoped>
	.base-message {
		::v-deep {
			.uv-cell-group {
				.cus-value {
					font-size: 14px;
					font-weight: 400;
					color: #a1a1a2;
				}
			}
		}
	}
</style>